#! /bin/bash
srv_name=gindemo
pid=`ps -ef|grep ${srv_name}|grep -v grep|awk '{print $2}'`
# 检查pid变量是否为空
if [ -z "${pid}" ]; then
    echo "Process not running."
else
    echo "Process is running with PID ${pid}"
    #kill -9 "${pid}"
    ps aux|grep $srv_name | grep -v grep | awk '{print $2}' | xargs kill -9
fi

echo "开始启动"
chmod +x $srv_name
BUILD_ID=DongKillMe
JENKINS_NODE_COOKIE=dontKillMe
nohup ./$srv_name > $srv_name.log 2>&1 &
echo "启动结束"